<template>
  <el-drawer
    v-model="showDrawer"
    title="修改密码"
    size="45%"
    :close-on-click-modal="false"
    :destroy-on-close="destroyOnClose"
  >
    <div class="formDrawer">
        <div class="body">
            <slot></slot>
        </div>
        <div class="actions">
            <el-button type="primary"
            :loading="loading" 
            @click="submit"
            >{{confirmText}}</el-button
          >
        <el-button @click="close">取消</el-button>
        </div>
    </div>
  </el-drawer>
</template>
<script setup>
import { ref } from "vue";
const prop = defineProps({
    title:String,
    size:{
        type:String,
        default:"45%"
    },
    destroyOnClose:{
        type:Boolean,
        default:false
    },
    confirmText:{
        type:String,
        default:'提交'
    },
})
const loading = ref(false)
const showLoading=()=>loading.value=true
const hideLoading=()=>loading.value=false
const emit=defineEmits(["submit"])
// 提交
const submit=()=>{
    emit("submit")
}
const showDrawer = ref(false);
// 打开
const open = () => (showDrawer.value = true);
// 关闭
const close = () => (showDrawer.value = false);
defineExpose({
  open,
  close,
  showLoading,
  hideLoading
});
</script>
<style lang="scss" scoped>
.formDrawer{
    width: 100%;
    height: 100%;
    position: relative;
    @apply flex flex-col;
}
.body{
    top: 0;
    left: 0;
    right: 0;
    bottom: 50px;
    flex: 1;
    position: absolute;
    overflow-y: auto;
}
.actions{
    height: 50px;
    @apply mt-auto flex items-center;
}
</style>